package com.cennavi.controller;

import com.cennavi.service.ScoreService;
import com.cennavi.utils.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * Created by lixiaoshuang on 2018/10/18.
 */
@Controller
public class ScoreController {
    @Autowired
    ScoreService scoreService;
    @RequestMapping("/getdata")
    public  @ResponseBody Object getdata(@RequestParam(value="data")String data){
//        List<Map> list=new ArrayList<>();
//        for(int i=0;i<4;i++){
//            Map map=new HashMap<>();
//            map.put("type",1);
//            map.put("cartype",1);
//            map.put("carid",i);
//            map.put("km",i+1);
//            list.add(map);
//        }
//        System.out.print("json:"+JSONObject.toJSON(list));
        Object obj= JsonUtil.toObject(data, List.class);
        List list=(List)obj;
        return scoreService.getScore(list);
    }

}
